package com.cskaoyan.javase.oop1._11static._4exercise.upgrade;

import jdk.management.resource.internal.inst.SocketOutputStreamRMHooks;

/**
 *
 * @since 11:20
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    static {
        System.out.println("Demo类开始初始化步骤了!");
    }
    static Cat cat = new Cat();

    Dog dog = new Dog();
    Dog dog2;

    // 启动main方法,触发该类的类加载,该类类加载完毕后,才会启动main方法
    public static void main(String[] args) {
        System.out.println("hello world!");
        Demo d = new Demo();
    }

    public Demo() {
        System.out.println("demo");
    }
}

class Cat {
    static {
        System.out.println("Cat类开始初始化步骤了!");
    }
    static Dog dog = new Dog();

    public Cat() {
        System.out.println("cat");
    }
}

class Dog {
    static {
        System.out.println("Dog类开始初始化步骤了!");
    }
    static Demo demo = new Demo();
    public Dog() {
        System.out.println("dog");
    }
}
